package com.iee.jvm;

import org.openjdk.jol.info.ClassLayout;
/** 查看对象内存大小 */
public class ClassLayoutDemo {
    private static class T{
        int i;  //4byte
        long p; //8byte
        String ss="123455556677899"; //4byte
    }

    public static void main(String[] args) {
        T t = new T();
        /**
         * <!--pom添加 查看对象头工具-->
         * <dependency>
         *     <groupId>org.openjdk.jol</groupId>
         *     <artifactId>jol-core</artifactId>
         *     <version>0.9</version>
         * </dependency>
         */
        System.out.println(ClassLayout.parseInstance(t).toPrintable());
    }
}
